package com.yoomiito.app.ui.my.angle

import cn.droidlover.xdroidmvp.net.ApiException
import cn.droidlover.xdroidmvp.net.ApiSubscriber
import cn.droidlover.xdroidmvp.net.XApi
import com.yoomiito.app.base.AppConfig
import com.yoomiito.app.base.BaseActPresenter
import com.yoomiito.app.model.my.AgreementInfo
import com.yoomiito.app.net.YmApi

class SignAgreementPresenter(appConfig: AppConfig) :BaseActPresenter<SignAgreementActivity>(appConfig){

    fun agreement(){
        YmApi.getYmService()
                .angleAgreement()
                .compose(v.bindToLifecycle())
                .compose(XApi.getApiTransformerData())
                .compose(XApi.getScheduler())
                .subscribe(object :ApiSubscriber<AgreementInfo>(handleException()){
                    override fun onSuccess(t: AgreementInfo?) {
                        v.showAgreement(t?.url)
                    }

                    override fun onFail(error: ApiException?) {
                        v.dismissLoading()
                    }
                })
    }
}